package cn.dev.mybatis.handler.executor;

import cn.dev.mybatis.bean.SqlObject;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UpdateSqlExecutor extends AbstractSqlExecutor {
    public UpdateSqlExecutor(SqlObject sqlObject) {
        super(sqlObject);
    }

    @Override
    public Object execute(Connection connection) throws SQLException {
        String originSql = sqlObject.getOriginSql();
        PreparedStatement preparedStatement = connection.prepareStatement(originSql);
        addParam(preparedStatement, sqlObject.getParamValue());
        return preparedStatement.executeUpdate();
    }
}
